Skip to content

Reimplement 1 Credits function at 100% from #531 - #548

Merged
TheRedDaemon merged 8 commits into
sourcehold:mainfrom
gynt:reimpl/pr531-matched
Dec 4, 2026
Merged

TheRedDaemon merged 8 commits into
sourcehold:mainfrom
gynt:reimpl/pr531-matched

Conversation

@gynt

@gynt gynt commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

This PR carries the finished part of draft #531 (reimpl/ui-rendering-directdraw-development). That is one function, UI::Credits::InsertElementIntoArrayAt_ec0348_2. The file is taken unchanged from the draft and compiles against main's headers as it is.

Measured on origin/main (40cbb1c): I ran a full DLL build with only this file in cmake/openshc-sources.txt.local. Both resolver sets were switched on: the struct resolvers through enable_reimplemented_data.py and the function resolver through enable_local_functions.py. I then ran reccmp.

Function Address reccmp raw / normalized Status remark
UI::Credits::InsertElementIntoArrayAt_ec0348_2 0x004DAE90 95.7 / 94.7 100.0% | Reimplemented (counted: only the 31.0f float constant name and the array-end data label differ)

The only differences in the reccmp diff are labels, so the function counts as 100% under main's convention:

  • fld dword ptr [<OFFSET>] in the original against fld dword ptr [31.0 (FLOAT)] in ours;
  • cmp ecx, I<int>::instance in the original against cmp ecx, cached in ours. This is the end-of-array address of DAT_ARRAY_00ec0348, labelled differently.

Header changes: none. The two enum headers this function uses (values taken from RenderActiveCreditsElements) are on main now, identical, through 0701799 ("upstream ghidra changes"), and the branch merges it:

  • UI/Enums/CreditsElementType.hpp (+Int): CET_NONE, CET_IMAGE, CET_TEXT, CET_HOVER_IMAGE, CET_BORDERED_BOX.
  • UI/Enums/CreditsFadeMode.hpp (+Int): CFM_NONE, CFM_FADE_IN (blend strength 31 down to 1), CFM_FADE_OUT (1 up to 31, then the element is freed).

GL / visibility entries: none. The draft adds /GL and visibility entries only so that ProcessCreditsScriptCommands can see its InsertElement* callees. That function stays in the draft, and this function matches without them.

Overlap with open PRs: none. No other open PR touches this file.

Left in the draft:

  • ProcessCreditsScriptCommands (83.0%): the case-4 scheduling and the placement of the case-22 edge block still differ.
  • WindowMsgProcessingFunc (86.8%): the block layout still differs, not just register allocation.

Draft #531 stays open for those two functions.

I re-checked both with the clarified "register allocation only" rule (no functional difference, and only allocation-kind differences left), and neither qualifies:

  • ProcessCreditsScriptCommands: the case-22 edge block sits in a different place, and the scheduling differs.
  • WindowMsgProcessingFunc: block layout differs, memory operands are folded into the instructions in one version and loaded separately in the other, and lea is used in place of add.

Style pass (88b70cd): InsertElementIntoArrayAt_ec0348_2 now follows REIMPLEMENTATION_STYLE_GUIDE.md as it is on main.

  • Named parameters (elementType, fadeMode, field20Unk/field24Unk/field28Unk) instead of param_N, and freeIndex instead of _index.
  • Early returns instead of the nested ifs, and an else-if for the fade mode.
  • countof(DAT_ARRAY_00ec0348::instance) instead of 24.
  • No trailing return;, and comments on the closing namespaces.

Re-measured with a full build and reccmp: unchanged at 95.7 / 94.7, and only the labels differ. No change had to be reverted.

Pre-review pass (e910e4b): merged main 592a17d, and the function now uses the two enums instead of raw numbers. The measurement is unchanged at 95.7 / 94.7.

Merge of main 0701799: a full build with both resolver sets and reccmp give the same 95.7 / 94.7, with only the same two labels differing.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp

…0348_2

Taken from draft sourcehold#531. Measured on main 40cbb1c with only this file in
.local and both resolver sets enabled: reccmp 95.7% raw, the only
differences being the 31.0f float constant name and the array-end data
label, so it is counted as 100% per main's convention.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

Style guide reading (advisory, posted once)

1 possible deviation(s) from REIMPLEMENTATION_STYLE_GUIDE.md across 1 of the 1 reimplemented .cpp file(s) in this PR.

The match comes first. Where the ugly form is what matched, it stays -- that is the guide's own overriding rule, and rule 21 asks for a one-line comment saying what was measured so the next reader does not retry it. This report is posted once, when the PR opens, and is not repeated on later pushes.

rule what it asks hits
1 Drop the decompiler trailing return; 1
Where

Rule 1 — Drop the decompiler trailing return;

  • src/OpenSHC/UI/Credits/InsertElementIntoArrayAt_ec0348_2.cpp:41 — trailing return; in a void function

gynt and others added 5 commits December 4, 2026 15:30
…UIDE

- named parameters (elementType, fadeMode, field20Unk/field24Unk/field28Unk)
  and freeIndex instead of param_N/_index
- early returns instead of the nested ifs, else-if for the fade mode
- countof(DAT_ARRAY_00ec0348::instance) instead of 24
- dropped the trailing return; namespace closing comments

Re-measured on main 40cbb1c: unchanged at 95.7 / 94.7, only the 31.0f
constant name and the array-end label differ.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
The values follow RenderActiveCreditsElements on main: 0 is a free slot,
1 an image, 2 text, 3 a hover image and 4 a bordered box.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
The values follow RenderActiveCreditsElements on main: 1 lowers
blendStrength to below 1 and then clears the mode (fade in), 2 raises it
past 31 and then frees the element (fade out).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
CET_TEXT / CET_NONE for the element type and CFM_FADE_IN / CFM_FADE_OUT for
the fade mode instead of raw numbers. Re-measured on main 592a17d with a
full build and reccmp: unchanged at 95.7 / 94.7 (only the 31.0f constant
name and the array-end label differ).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
@github-actions github-actions Bot added the declaration/type change This requires changes to the generated/exported types or definitions. label Dec 4, 2026
@gynt

gynt commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

No match-driven forms remain in InsertElementIntoArrayAt_ec0348_2. Two notes on the headers, which this PR leaves unchanged:

  • Credits.hpp names the parameters (param_1, xSpace, param_3, param_4, ySpace, someX, param_7, someY, param_9). The function stores them into type, xSpace, field_0x20, field_0x28, x, y, fadeMode, width, field_0x24. The .cpp uses names that match those stores (elementType, x, y, fadeMode, width, ...).
  • CreditsRelatedStructure.type and .fadeMode are int. They could become CreditsElementTypeInt/CreditsFadeModeInt once that is upstreamed. Until then the .cpp compares the int fields with the new enum values.

…1-matched

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
@github-actions github-actions Bot removed the declaration/type change This requires changes to the generated/exported types or definitions. label Dec 4, 2026
@TheRedDaemon
TheRedDaemon added this pull request to the merge queue Dec 4, 2026
Merged via the queue into sourcehold:main with commit e3e4265 Dec 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants